<template>
	<view class="">
		<view class="cu-card dynamic" :class="isCard?'no-card':''">
			<view class="cu-item shadow padding" v-for="(post,index) in [message]" :key="index">
				<view class="cu-list menu-avatar">
					<view class="cu-item">
						<view  class="cu-avatar round lg" :style="{'background-image':'url('+post.from.avatar+')'}">
							
						</view>
						<view class="content">
							<view class="text-left text-gray">{{post.from.name}}</view>
							<view class="text-gray text-sm flex justify-between">
								{{post.sended_at}}
							</view>
						</view>
						
					</view>
				</view>
				<block v-if="post.data.extra.post_messages" v-for="(message,index1) in post.data.extra.post_messages" :key="index1">
					
					<view class="text-left text-content text-black" v-if="message.message_type=='text'">
						{{message.data.content}}
					</view>
					<view class="flex justify-center padding-xs" v-else-if="message.message_type=='video'">
						<video style="width:280px"  id="myVideo" :src="message.data.content"
						                    controls></video>
					</view>
					<view class="flex justify-center padding-xs" v-else-if="message.message_type=='image'">
						<view v-if="message.data.extra&&message.data.extra.images"  class="grid flex-sub padding-lr" :class="message.data.extra.images.length>=3?'col-3 grid-square':('grid-square '+'col-'+message.data.extra.images.length)" style="width: calc(100vw - 260rpx);">
							<view  @tap="imViewImage" class="bg-img" :class="" 
							 v-for="(item,index) in message.data.extra.images" :key="index" :src="$tool.chat_img_url(item)" :data-url="$tool.chat_img_url(item)" :style="{'background-image':('url('+item+')')}">
							</view>
						</view>
					</view>
				</block>
				
		
				<view class="text-gray text-sm text-right">
					<chat-vote :message="post"></chat-vote>
				</view>
		
			</view>

		</view>
	</view>

</template>

<script>
	import app from '@/mixins/app.js'
	export default {
		data(){
			return {
				isCard:false
			}
		},
		mixins:[app],
		props: {
			message: {
				type: [Object],
				default:()=>{
					return {}
				}
			},	
			current_images: {
				type: [Array],
				default:()=>{
					return []
				}
			},
		},
		computed:{
			
		},
		methods:{
			imViewImage(e) {
				console.log(this.current_images,e.currentTarget.dataset.url,333333)
				uni.previewImage({
					urls: this.current_images,
					current: e.currentTarget.dataset.url
				});
			},
		}
	}
</script>

<style>
</style>
